#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <stdlib.h>

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int checkVillageEffect(int currentPlayer, int card, struct gameState *state);

int checkVillageEffect(int currentPlayer, int card, struct gameState *state){
    int r;

    int handPos = floor(Random() * state->handCount[currentPlayer]);

    struct gameState pre;
    memcpy (&pre, state, sizeof(struct gameState));

    r = villageCard(*state, currentPlayer, handPos);

    //Add 1 Card
    drawCard(currentPlayer, &pre);

    //Add 2 Actions
    pre.numActions = pre.numActions + 2;

    //discard played card from hand
    discardCard(handPos, currentPlayer, &pre, 0);

    assert (r == 0);
	assert(memcmp(&pre, state, sizeof(struct gameState)) == 0);


    return 0;
}

int main(){

    int currentPlayer;

    struct gameState g;

    printf ("Testing Great Hall Card Effect.\n");

    g.whoseTurn = floor(Random() *MAX_PLAYERS);
    currentPlayer = g.whoseTurn;
    g.deckCount[currentPlayer] = floor(Random() * MAX_DECK);
    g.discardCount[currentPlayer] = floor(Random() * MAX_DECK);
    g.handCount[currentPlayer] = floor(Random() * MAX_HAND);
    g.playedCardCount = floor(Random() * MAX_DECK);
    checkVillageEffect(currentPlayer, great_hall, &g);

    printf("Village card OK\n");

    return 0;
}
